<?php

class Default_Model_SeatMap {
	protected $_seatmapId;
	protected $_bitmapUrl;
	protected $_event;
	protected $_reservationDuration;
	
	function __construct() {
		
	//TODO - Insert your code here
	}

	public function __set($name, $value)
    {
        $method = 'set' . $name;
        if (!method_exists($this, $method)) {
            throw new Exception('Invalid Seatmap property');
        }
        $this->$method($value);
    }

    public function __get($name)
    {
        $method = 'get' . $name;
        if (!method_exists($this, $method)) {
            throw new Exception('Invalid Seatmap property');
        }
        return $this->$method();
    }
    
	/**
	 * @param $_reservationDuration the $_reservationDuration to set
	 */
	public function setReservationDuration($_reservationDuration) {
		if (($_reservationDuration < 1 )) {
			throw new Exception('Invalid reservation duration');
		}
		$this->_reservationDuration = $_reservationDuration;
	}

	/**
	 * @param $_event the $_event to set
	 */
	public function setEvent($_event) {
		$this->_event = $_event;
	}

	/**
	 * @param $_bitmapUrl the $_bitmapUrl to set
	 */
	public function setBitmapUrl($_bitmapUrl) {
		$this->_bitmapUrl = trim($_bitmapUrl);
	}

	/**
	 * @param $_seatmapId the $_seatmapId to set
	 */
	public function setSeatmapId($_seatmapId) {
		$this->_seatmapId = $_seatmapId;
	}

	/**
	 * @return the $_reservationDuration
	 */
	public function getReservationDuration() {
		return $this->_reservationDuration;
	}

	/**
	 * @return the $_event
	 */
	public function getEvent() {
		return $this->_event;
	}

	/**
	 * @return the $_bitmapUrl
	 */
	public function getBitmapUrl() {
		return $this->_bitmapUrl;
	}

	/**
	 * @return the $_seatmapId
	 */
	public function getSeatmapId() {
		return $this->_seatmapId;
	}
	
	public function setMapper($mapper)
    {
        $this->_mapper = $mapper;
        return $this;
    }

    public function getMapper()
    {
        if (null === $this->_mapper) {
            $this->setMapper(new Default_Model_SeatMapMapper());
        }
        return $this->_mapper;
    }

    public function save()
    {
        $this->getMapper()->save($this);
    }

    public function find($id)
    {
        $this->getMapper()->find($id, $this);
        return $this;
    }

    public function fetchAll()
    {
        return $this->getMapper()->fetchAll();
    }
	
}

?>